﻿@{
    Bundle("jquery_jqGrid");
}

<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('@ID("#grid")').jqGrid({
            mtype: 'post',
            url: '@Url.Action(Loc.Act("Grid"))',
            postData: {
                searchTerm: '@Request.QueryParam("searchTerm")',
                memberID: '@Request.QueryParam("memberID")',
                forumID: '@Request.QueryParam("forumID")',
                createdFrom: '@Request.QueryParam("createdFrom")',
                createdTo: '@Request.QueryParam("createdTo")',
                flagMask: '@Request.QueryParam("flagMask", "None")'
            },
            colNames:
            [
                '#',
                '@T(Res.Name("Forum"))',
                '@T(Res.Name("Member"))',
                '@T(Res.Name("Title"))',
                '@T(Res.Name("PostCount"))',
                '&#10001;',
                '&#9998'
            ],
            colModel: 
            [
                { name: 'EntityID', align: 'center', width: 50, fixed: true, index: 'ID', title: false },
                { name: 'Forum', align: 'center', width: 100, fixed: true, sortable: false, title: false },
                { name: 'Member', align: 'center', width: 200, fixed: true, sortable: false, title: false },
                { name: 'Title', index: 'Title', title: false },
                { name: 'PostCount', align: 'center', width: 100, fixed: true, index: 'PostCount', title: false },
                { name: 'CreatedOn', align: 'center', width: 200, fixed: true, index: 'CreatedOn', title: false },
                { name: 'Action', align: 'center', width: 100, fixed: true, sortable: false, title: false }
            ],
            gridComplete: function () {
                var ids = jQuery('@ID("#grid")').jqGrid('getDataIDs');
                for (var i = 0; i < ids.length; i++) {
                    var actEdit = '<a href="@Url.Action(Loc.Act("Edit"))?id=' + ids[i] + '">@T(Res.In("Common").Of("Act").Name("Edit"))</a>';
                    jQuery('@ID("#grid")').jqGrid('setRowData', ids[i], { Action: actEdit });
                }
            },
            sortname: 'ID',
            sortorder: 'asc',
            pager: '@ID("#grid_pager")'
        });
    });
</script>
<table class="grid" id="@ID("grid")"></table>
<div class="pager" id="@ID("grid_pager")"></div>